/**
 */
package sdmakerz_v1.coresyntax.sDMakerV1.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import sdmakerz_v1.coresyntax.sDMakerV1.Eval;
import sdmakerz_v1.coresyntax.sDMakerV1.Reference;
import sdmakerz_v1.coresyntax.sDMakerV1.SDMakerV1Package;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Eval</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link sdmakerz_v1.coresyntax.sDMakerV1.impl.EvalImpl#getDiagRef <em>Diag Ref</em>}</li>
 *   <li>{@link sdmakerz_v1.coresyntax.sDMakerV1.impl.EvalImpl#getConfigRefs <em>Config Refs</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class EvalImpl extends ElementImpl implements Eval
{
  /**
   * The cached value of the '{@link #getDiagRef() <em>Diag Ref</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDiagRef()
   * @generated
   * @ordered
   */
  protected Reference diagRef;

  /**
   * The cached value of the '{@link #getConfigRefs() <em>Config Refs</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getConfigRefs()
   * @generated
   * @ordered
   */
  protected EList<Reference> configRefs;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected EvalImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return SDMakerV1Package.Literals.EVAL;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Reference getDiagRef()
  {
    return diagRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetDiagRef(Reference newDiagRef, NotificationChain msgs)
  {
    Reference oldDiagRef = diagRef;
    diagRef = newDiagRef;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SDMakerV1Package.EVAL__DIAG_REF, oldDiagRef, newDiagRef);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDiagRef(Reference newDiagRef)
  {
    if (newDiagRef != diagRef)
    {
      NotificationChain msgs = null;
      if (diagRef != null)
        msgs = ((InternalEObject)diagRef).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - SDMakerV1Package.EVAL__DIAG_REF, null, msgs);
      if (newDiagRef != null)
        msgs = ((InternalEObject)newDiagRef).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - SDMakerV1Package.EVAL__DIAG_REF, null, msgs);
      msgs = basicSetDiagRef(newDiagRef, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, SDMakerV1Package.EVAL__DIAG_REF, newDiagRef, newDiagRef));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Reference> getConfigRefs()
  {
    if (configRefs == null)
    {
      configRefs = new EObjectContainmentEList<Reference>(Reference.class, this, SDMakerV1Package.EVAL__CONFIG_REFS);
    }
    return configRefs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case SDMakerV1Package.EVAL__DIAG_REF:
        return basicSetDiagRef(null, msgs);
      case SDMakerV1Package.EVAL__CONFIG_REFS:
        return ((InternalEList<?>)getConfigRefs()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case SDMakerV1Package.EVAL__DIAG_REF:
        return getDiagRef();
      case SDMakerV1Package.EVAL__CONFIG_REFS:
        return getConfigRefs();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case SDMakerV1Package.EVAL__DIAG_REF:
        setDiagRef((Reference)newValue);
        return;
      case SDMakerV1Package.EVAL__CONFIG_REFS:
        getConfigRefs().clear();
        getConfigRefs().addAll((Collection<? extends Reference>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case SDMakerV1Package.EVAL__DIAG_REF:
        setDiagRef((Reference)null);
        return;
      case SDMakerV1Package.EVAL__CONFIG_REFS:
        getConfigRefs().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case SDMakerV1Package.EVAL__DIAG_REF:
        return diagRef != null;
      case SDMakerV1Package.EVAL__CONFIG_REFS:
        return configRefs != null && !configRefs.isEmpty();
    }
    return super.eIsSet(featureID);
  }

} //EvalImpl
